package com.creatapark.mapper;

import com.creatapark.entity.DerationData;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * DerationDataMapper
 *
 * @author Bruce01.fan
 * @date 2017/7/21
 */
@Mapper
public interface DerationDataMapper {

    @Results({
            @Result(property = "parkName",column = "park_name"),
            @Result(property = "diffTime",column = "diffTime"),
            @Result(property = "inTime",column = "in_time"),
            @Result(property = "outTime",column = "out_time")
    })
    @Select("select p.`park_name`,timediff(car.`out_time`,car.`in_time`) ,car.`in_time`,car.`out_time` " +
            "from t_park_info p,t_car_inout_data car " +
            "where p.`park_id` = car.`park_id`" +
            "and car.`in_time` > #{staTime} " +
            "and car.`out_time` <= #{endTime} " +
            "and p.`park_id`=#{parkId} " +
            "order by car.`out_time` asc")
    List<DerationData> getDerationData(@Param("parkId") Long parkId,@Param("staTime") String staTime, @Param("endTime") String endTime);

}